﻿/* *****************************************************************************
 * @ Encoding: UTF-8
 * @ File Name: naughty_differential_node_sub.cpp
 * @ Author: carl
 * @ Email: naughtygeng@qq.com
 * @ Created Time: 2022-7月-12(星期二) 21:15:30
 * @ All Rights Reserved
 * *****************************************************************************/

#include "naughty_differential_node_sub.hpp"

namespace naughty_differential
{

node_sub::node_sub(std::shared_ptr<node_base> param01, std::shared_ptr<node_base> param02)
    :
        node_base({param01, param02})
{

}

node_sub::node_sub(std::vector<std::shared_ptr<node_base>> params)
    :
        node_base(params)
{

}

std::shared_ptr<node_base> node_sub::differential(std::string variable)
{
    return std::make_shared<node_sub>(get_parameters()[0]->differential(variable), get_parameters()[1]->differential(variable));
}

enum node_type node_sub::get_node_type()
{
    return node_type_sub;
}

std::string node_sub::serialize()
{
    return {};
}

std::string node_sub::to_string() const
{
	return std::string("(") + get_parameters()[0]->to_string() + ") - (" + get_parameters()[1]->to_string() + ")";
}

std::shared_ptr<node_base> node_sub::clone()
{
    return std::make_shared<node_sub>(parameters_clone());
}

double node_sub::get_value(std::map<std::string, double> val_value_map)
{
    std::vector<double> params_value = get_params_value(val_value_map);

    return params_value[0] - params_value[1];
}

std::string node_sub::identity_string() const
{
	return std::string("sub(") + get_parameters()[0]->to_string() + ", " + get_parameters()[1]->to_string() + ")";
}

}
